export default [
  {
    path: "/home",
    component: () => import("@/views/Home"),
    name: "Home"
  },
  {
    path: "/login",
    component: () => import("@/views/Login"),
    name: "Login",
    meta: {
      FooterIsHidden: true,
    },

  },
  {
    path: "/search/:keyword?",
    component: () => import("@/views/Search"),
    name: "Search",
    props(route) {
      return {
        ...route.query,
        ...route.params
      };
    }

  },
  {
    path: "/register",
    component: () => import("@/views/Register"),
    name: "Register",
    meta: {
      FooterIsHidden: true,
    },
  },
  {
    path: "/detail/:skuId",
    component: () => import("@/views/Detail"),
    name: "Detail",
  },
  {
    path: "/addcartsuccess",
    component: () => import("@/views/AddCartSuccess"),
    name: "AddCartSuccess",
  },
  {
    path: "/shopcart",
    component: () => import("@/views/ShopCart"),
    name: "ShopCart",
  },
  {
    beforeEnter: (to, from, next) => {
      if (from.name == "ShopCart") {
        next();
      } else {
        alert("请在购物车结算");
        next("/shopcart");
      }
    },
    path: "/trade",
    component: () => import("@/views/Trade"),
    name: "Trade",
  },
  {
    beforeEnter: (to, from, next) => {
      if (from.name == "Trade") {
        next();
      } else {
        alert("请在购物车结算");
        next("/shopcart");
      }
    },
    path: "/pay",
    component: () => import("@/views/Pay"),
    name: "Pay",
  },
  {
    beforeEnter: (to, from, next) => {
      if (from.name == "Pay") {
        next();
      } else {
        alert("请在购物车结算");
        next("/shopcart");
      }
    },
    path: "/paysuccess",
    component: () => import("@/views/PaySuccess"),
    name: "PaySuccess",
  },
  {
    path: "/center",
    component: () => import("@/views/Center"),
    name: "Center",
    redirect: "/center/myorder",
    children: [
      {
        path: "myorder",
        component: () => import("@/views/Center/components/MyOrder"),
        name: "MyOrder",
      },
      {
        path: "tremorder",
        component: () => import("@/views/Center/components/TremOrder"),
        name: "TremOrder",
      }
    ]
  },
  {
    path: "/",
    redirect: "/home"
  },
  {
    path: "/*",
    component: () => import("@/views/404")
  }
];